package com.zking.easyuidemo.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lisen.mvc.framework.AbstractDispatchAction;
import org.lisen.mvc.framework.ModelDrive;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zking.easyuidemo.dao.ModuleDao;
import com.zking.easyuidemo.model.Module;

public class ModuleAction extends AbstractDispatchAction implements ModelDrive {
	
	private Module module = new Module();

	@Override
	public Object getModel() {
		return module;
	}
	
	private ModuleDao moduleDao = new ModuleDao();
	
	
	public void getModules(HttpServletRequest req, HttpServletResponse resp) throws Exception {
		
		List<Module> datas = moduleDao.getModules(module.getPid());
		
		ObjectMapper mapper = new ObjectMapper();
		//mapper.writeValueAsString(datas);
		mapper.writeValue(resp.getOutputStream(), datas);
		
	}
	

}
